package com.ias.agdis_r.util.flight;

import java.util.HashMap;
import java.util.Map;

import com.ias.agdis_r.util.S;

public class DataParser {

	/**
	 * 将rtl解析为Map对象，
	 * 如"LK_ZKYD,找客引导,LK_HYAP,航延安排,LK_DANJA,特服-担架,LK_WP,特服-无陪,LK_LY,特服-轮椅,LK_DJ,登机,LK_LJ,离机"解析为
	 * ：{离机=LK_LJ, 登机=LK_DJ, 找客引导=LK_ZKYD, 特服-无陪=LK_WP, 特服-轮椅=LK_LY,
	 * 航延安排=LK_HYAP, 特服-担架=LK_DANJA}
	 * 
	 * @param rtl：类似"LK_ZKYD,找客引导,LK_HYAP,航延安排"
	 * @return:成功解析返回Map，否则返回Null
	 */
	public static Map<String, String> parseRtlToMap(String rtl) {
		if (S.isEmpty(rtl)) {
			return null;
		}
		String[] strs = rtl.split(",");
		Map<String, String> map = new HashMap<String, String>();
		for (int i = 0; i < strs.length; i += 2) {
			map.put(strs[i + 1], strs[i]);
		}
		return map.size() == 0 ? null : map;
	}

	private DataParser() {
	}

}
